*	----------------------------------------------------------------------------
*	File Name: wp_2019_code.do       
*	Authors:   Kanchan Chandra & Omar García-Ponce      
*	Date:  	   December, 2018       
*	Purpose:   Replicate results from "Why Subaltern-led Parties Crowd Out Armed 
*			   Organizations: Explaining Maoist Violence in India." Published in
*			   World Politics, 2019. 
*	Software:  Stata 15                       
*	----------------------------------------------------------------------------

clear all

******************************************************************************** 
************************* CROSS-SECTIONAL ANALYSIS *****************************
******************************************************************************** 

use "~/cross_sectional.dta"

set more off

*	----------------------------------------------------------------------------
*	Table 1: DESCRIPTIVE STATISTICS OF KEY VARIABLES
*	----------------------------------------------------------------------------
sum vlnc8108 subaltern logarea logelev logforest minerals priorvlnce landholdings literacy sc st marginal brit commbase murder7276 riots7276 noncongress left parties scquota stquota logpop

*	----------------------------------------------------------------------------
*	Table 2: SUBALTERN INCORPORATION & MAOIST VIOLENCE--CROSS-SECTIONAL RESULTS
*	----------------------------------------------------------------------------
eststo clear
qui zinb vlnc8108 subaltern, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce logarea logelev logforest minerals, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce logarea logelev logforest minerals landholdings literacy sc st marginal, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce logarea logelev logforest minerals brit commbase, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce logarea logelev logforest minerals murder7276 riots7276, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce logarea logelev logforest minerals noncongress left parties scquota stquota, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zinb vlnc8108 subaltern priorvlnce logarea logelev logforest minerals brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui zip vlnc8108 subaltern priorvlnce logarea logelev logforest minerals brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota, inflate(priorvlnce minerals commbase logpop) vce(robust) exp(logpop) 
eststo
qui reg vlnc8108 subaltern priorvlnce logpop logarea logelev logforest minerals brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota if vlnc8108>0, r
eststo
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) stats(N rmse r2) mtitle("zinb " "zinb " "zinb " "zinb " "zinb " "zinb" "zinb" "zinb" "zip" "OLS")

*	----------------------------------------------------------------------------
*	Table 3: CROSS-SECTIONAL RESULTS USING ORDINAL SCALES OF MAOIST VIOLENCE
*	----------------------------------------------------------------------------
* Panel A
eststo clear
qui reg ord_vlnc subaltern , r 
eststo
qui reg ord_vlnc subaltern priorvlnce logarea logelev logforest minerals , r 
eststo
qui reg ord_vlnc subaltern priorvlnce logarea logelev logforest minerals logpop brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota , r 
eststo
qui ologit ord_vlnc subaltern , r 
eststo
qui ologit ord_vlnc subaltern priorvlnce logarea logelev logforest minerals , r 
eststo
qui ologit ord_vlnc subaltern priorvlnce logarea logelev logforest minerals logpop brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota , r 
eststo
esttab, replace b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) keep(subaltern) stats(N rmse r2) mtitle()
* Panel B
eststo clear
qui reg ord_deaths subaltern , r 
eststo
qui reg ord_deaths subaltern priorvlnce logarea logelev logforest minerals , r 
eststo
qui reg ord_deaths subaltern priorvlnce logarea logelev logforest minerals logpop brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota , r 
eststo
qui ologit ord_deaths subaltern , r 
eststo
qui ologit ord_deaths subaltern priorvlnce logarea logelev logforest minerals , r 
eststo
qui ologit ord_deaths subaltern priorvlnce logarea logelev logforest minerals logpop brit commbase landholdings literacy sc st marginal murder7276 riots7276 noncongress left parties scquota stquota , r 
eststo
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01)  keep(subaltern) stats(N rmse r2) mtitle()

*	----------------------------------------------------------------------------
*	Table 4: PRIOR MAOIST VIOLENCE AND SUBALTERN INCORPORATION
*	----------------------------------------------------------------------------
eststo clear
qui reg subaltern drate6776, r
eststo
qui reg subaltern drate6776 logarea logelev logforest minerals, r
eststo
qui reg subaltern drate6776 logarea logelev logforest minerals brit commbase landholdings literacy sc st marginal murder7276 riots7276, r 
eststo
qui reg subaltern drate6776 if vlnc6776 !=0, r
eststo
qui reg subaltern drate6776 logarea logelev logforest minerals if vlnc6776 !=0, r
eststo
qui reg subaltern drate6776 logarea logelev logforest minerals brit commbase landholdings literacy sc st marginal murder7276 riots7276 if vlnc6776 !=0, r 
eststo
esttab, compress b(%8.2f) se(%8.2f) keep(drate6776) star(* 0.10 ** 0.05 *** 0.01) stats(N rmse r2)


******************************************************************************** 
**************************** TWO-PERIOD ANALYSIS *******************************
******************************************************************************** 

use "~/two_period.dta", clear

gen rulXpost = ruling*post
gen subXpost = subaltern*post

set more off

*	----------------------------------------------------------------------------
*	Table 5: SUBALTERN INCORPORATION AND MAOIST VIOLENCE—DIFF-IN-DIFF RESULTS
*	----------------------------------------------------------------------------
* Columns 1--3
eststo clear
qui xi: xtreg meanvlnc subXpost i.post*logpop post, fe r
eststo
qui xi: xtreg meanvlnc subXpost i.post*logpop i.minerals*post i.post*logarea i.post*logelev i.post*logforest, fe r
eststo 
qui xi: xtreg meanvlnc subXpost i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logpop i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota, fe r
eststo 
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) keep(subXpost) stats(N F rmse r2)

*	----------------------------------------------------------------------------
*	Table 6: “RULING” SUBALTERN INCORPORATION AND MAOIST VIOLENCE
*	----------------------------------------------------------------------------
* Columns 1--3
eststo clear
qui xi: xtreg meanvlnc rulXpost i.post*logpop post, fe r
eststo
qui xi: xtreg meanvlnc rulXpost i.post*logpop i.minerals*post i.post*logarea i.post*logelev i.post*logforest, fe r
eststo 
qui xi: xtreg meanvlnc rulXpost i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logpop i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota, fe r
eststo 
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) keep(rulXpost) stats(N rmse r2) 


******************************************************************************** 
************************** ANNUAL PANEL ANALYSIS *******************************
******************************************************************************** 

use "~/annual.dta", clear

tsset id year, yearly 

gen subXpost = subaltern*post
gen rulXpost = ruling*post
gen trend = year*subaltern
gen trendsq = (year^2)*subaltern

set more off

*	----------------------------------------------------------------------------
*	Table 5: SUBALTERN INCORPORATION AND MAOIST VIOLENCE—DIFF-IN-DIFF RESULTS
*	----------------------------------------------------------------------------
* Columns 4--9
eststo clear
qui xi: xtreg vlnc_dummy subXpost i.post*logpop i.year, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop i.minerals*post i.post*logarea i.post*logelev i.post*logforest i.year, fe cl(id)
eststo 
qui xi: xtreg vlnc_dummy subXpost i.post*logpop i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota i.year, fe cl(id)
eststo 
qui xi: xtlogit vlnc_dummy subXpost i.post*logpop i.year, fe 
eststo
qui xi: xtlogit vlnc_dummy subXpost i.post*logpop i.minerals*post i.post*logarea i.post*logelev i.post*logforest i.year, fe 
eststo
qui xi: xtlogit vlnc_dummy subXpost i.post*logpop i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota i.year, fe 
eststo 
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) keep(subXpost) stats(N F rmse r2)

*	----------------------------------------------------------------------------
*	Table 6: “RULING” SUBALTERN INCORPORATION AND MAOIST VIOLENCE
*	----------------------------------------------------------------------------
* Columns 4--9
eststo clear
qui xi: xtreg vlnc_dummy rulXpost i.post*logpop i.year, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy rulXpost i.post*logpop i.minerals*post i.post*logarea i.post*logelev i.post*logforest i.year, fe cl(id)
eststo 
qui xi: xtreg vlnc_dummy rulXpost i.post*logpop i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota i.year, fe cl(id)
eststo
qui xi: xtlogit vlnc_dummy rulXpost i.post*logpop i.year, fe 
eststo
qui xi: xtlogit vlnc_dummy rulXpost i.post*logpop i.minerals*post i.post*logarea i.post*logelev i.post*logforest i.year, fe 
eststo 
qui xi: xtlogit vlnc_dummy rulXpost i.post*logpop i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota i.year, fe 
eststo 
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) keep(rulXpost) stats(N F rmse r2)

*	----------------------------------------------------------------------------
*	Table 7: ROBUSTNESS TO TIME TRENDS AND SPATIAL CONFOUNDS
*	----------------------------------------------------------------------------
eststo clear
qui xi: xtreg vlnc_dummy subXpost i.post*logpop trend post, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop trendsq post, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop trend trendsq post, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.year i.post*logpop trend trendsq post, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop L1.nbr_vlnce  trend trendsq, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop L1.nbr_vlnce  i.year, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop i.year L1.nbr_vlnce  i.minerals*post i.post*logarea i.post*logelev i.post*logforest, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop i.year L1.nbr_vlnce  i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota, fe cl(id)
eststo
qui xi: xtreg vlnc_dummy subXpost i.post*logpop i.year trendsq L1.nbr_vlnce  i.minerals*post i.brit*post i.commbase*post i.post*logarea i.post*logelev i.post*logforest i.landholdings*post i.post*literacy i.post*sc i.post*st i.post*marginal i.post*murder7276 i.post*riots7276 i.post*left i.post*noncongress i.post*parties i.post*stquota i.post*scquota trend, fe cl(id)
eststo
esttab, compress b(%8.2f) se(%8.2f) star(* 0.10 ** 0.05 *** 0.01) stats(N F rmse r2) keep(subXpost L.nbr_vlnce)
 
